/**
 * @author		Sergey Suzdalskiy
 * @e-mail:		sergey.suzdalskiy@gmail.com
 */
package ua.kiev.gcore.ui.controls.gallery
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	
	
	public class GalleryItem implements IGalleryItem
	{
		private var _id:String;
		private var _type:String;
		private var _size:Point;
		private var _sprite:Sprite;
		
		public function GalleryItem(itemId:String, ItemType:String, ItemSprite:Sprite = null, itemSize:Point = null)
		{
			super();
			_id = itemId;
			_type = ItemType;			
			_size = itemSize;
			_sprite = ItemSprite;
			
			if((_sprite != null) && (_size == null)){
				_size = new Point(_sprite.width, _sprite.height);
			}
			if(sprite){
				sprite.addEventListener(Event.ADDED_TO_STAGE, addedToSage);
			}
		}
		private function removedFromStage(event:Event):void{
			sprite.removeEventListener(Event.REMOVED_FROM_STAGE, removedFromStage);
			sprite.addEventListener(Event.ADDED_TO_STAGE, addedToSage);
			hide();
			
		}
		private function addedToSage(event:Event):void{
			sprite.removeEventListener(Event.ADDED_TO_STAGE, addedToSage);
			sprite.addEventListener(Event.REMOVED_FROM_STAGE, removedFromStage);
			show();
		}
		
		public function get id():String{
			return _id;
		}
		
		public function get type():String{
			return _type;
		}
		
		public function get size():Point{
			if(!_size){
				_size = new Point();
			}
			return _size;
		}
		
		public function get sprite():Sprite{
			if(!_sprite){
				_sprite = new Sprite();
			}
			return _sprite;
		}
		protected function show():void{
			
		}
		protected function hide():void{
			
		}
		public function destroy():void{
			
		}
	}
}